package graphic.window;

/**
 * This class is using design pattern singleton. There will be exactly one window
 * in the whole application and this class is mentioned as global access point used
 * for painting. It saves a lot of work with passing reference through parameters.
 * 
 * @author Tomas Zima
 */
public class MainWindow extends GraphicContextWindow
{
	/**
	 * Constructor.
	 * Passes arguments to the GraphicContextWindow.
	 * 
	 * Remember, that this constructor is private because of singleton design
	 * pattern. It can be called ONLY from this class.
	 * 
	 * @param int [width]
	 *		Width of the created window.
	 * 
	 * @param int [height]
	 *		Height of the create window.
	 */
	private MainWindow(int width, int height)
	{
		super(width, height);
	}
	
	/**
	 * Returns instance of one (exactly one) existing MainWindow class.
	 * 
	 * @param void
	 * @return MainWindow
	 */
	public static MainWindow getInstance()
	{
		// No instance? Create!
		if (__instance == null)
		{
			__instance = new MainWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
			__instance.setTitle(WINDOW_TITLE);
		}
		
		// Return existing instance
		return __instance;
	}
	
	/**
	 * Initialization of static attributes.
	 */
	static
	{
		__instance	= null;		// No instance when creating
		
		// ToDo: Load these values from some config (it can be just static class
		// with constants.
		//WINDOW_WIDTH		= 800;		// Default window width
		//WINDOW_HEIGHT		= 600;		// Default window height
		
		WINDOW_WIDTH		= 900;
		WINDOW_HEIGHT		= 480;
		WINDOW_TITLE		= "Banda totalnich drtikolu";
	}
	
	private static MainWindow __instance;	// Reference to the instance of class
	
	protected static final int		WINDOW_WIDTH;	// Width of the window
	protected static final int		WINDOW_HEIGHT;	// Height of the window
	protected static final String	WINDOW_TITLE;	// Title of the window
}
